package edu.neu.wsy.controller;

import edu.neu.wsy.annotation.IgnoreResponseAdvice;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

/**
 * <h1>WangY的测试接口</h1>
 */
@RestController
@Slf4j
@RequestMapping("/example")
public class ExampleController {
    @GetMapping("/hello")
    @ApiOperation(httpMethod = "GET", value = "测试系统接口", notes = "返回hello world")
    public List<String> sayHelloWithCommonResponse() {
        List<String> res = new ArrayList<>();
        res.add("Hello World");
        return res;
    }

    @GetMapping("/hello-without-advice")
    @ApiOperation(httpMethod = "GET", value ="无结果返回接口", notes = "返回不带有包装的串")
    @IgnoreResponseAdvice
    public String sayHelloWithoutCommonResponse() {
        return "Hello World Pure";
    }

    @GetMapping("/hello-with-exception")
    @ApiOperation(httpMethod = "GET", value = "异常返回结果", notes = "系统异常处理测试")
    public String sayHelloWithException() {
        throw new RuntimeException("Hello Exception");
    }
}
